# 导包
import requests

# 创建员工管理模块封装的类
class EmpApi:
    # 封装添加员工接口
    def add_emp(self, token, json_dict):
        url = "http://ihrm-test.itheima.net/api/sys/user"
        header_dict = {"Authorization": token}
        return requests.post(url=url, headers=header_dict, json=json_dict)

    # 封装查询员工接口
    def query_emp(self, emp_id, token):
        url = "http://ihrm-test.itheima.net/api/sys/user/" + str(emp_id)
        header_dict = {"Authorization": token}
        return requests.get(url=url, headers=header_dict)

    # 封装修改员工接口
    def update_emp(self, emp_id, token, json_dict):
        url = "http://ihrm-test.itheima.net/api/sys/user/" + str(emp_id)
        header_dict = {"Authorization": token}
        json_dict = {"username": "xiaoming8"}
        return requests.put(url=url, headers=header_dict, json=json_dict)

    # 封装删除员工接口
    def del_emp(self, emp_id, token):
        url = "http://ihrm-test.itheima.net/api/sys/user/" + str(emp_id)
        header_dict = {"Authorization": token}
        return requests.delete(url=url, headers=header_dict)
